#ifndef GRAPH_H
#define GRAPH_H

#include <vector>
#include <list>
#include "prerequisites.h"

//Non-negative, directed, weighted graph
class Graph
{
public:
	typedef std::list<Connection*> AdjacentConnections;
public:
	Graph(uint32 size);
	~Graph();

	Node* getNode(const uint32 id) const;
	void addNode(Node* newNode);

	void addConnection(Connection* connection);

	//returns the connections from a given node
	AdjacentConnections getConnections(uint32 nodeId) const;

	//returns the total number of active nodes
	const uint32 getNodeAmount();
	//returns the total number of connections
	const uint32 getConnectionAmount();

private:
	/* For fast access nodes are stored in an vector
	* and the vector's key corresponds to the Node's id
	*/
	std::vector<Node*> nodes_;

	/* The Node's connections are stored in an adjacency list.
	* Connection lists are retrieved via the Connection vector,
	* where the node's id corresponds to vector's key
	*/
	std::vector<AdjacentConnections> nodeConnections_;

	bool isConnectionUnique(uint32 from, uint32 to);
	
};

#endif // GRAPH_H
